amazon 您所在的位置:网站首页 aws s3 transfer acceleration amazon

amazon

#amazon| 来源: 网络整理| 查看: 265

Enable transfer acceleration for an Amazon S3 bucket using an AWS SDK

The following code example shows how to enable transfer acceleration for an S3 bucket.

Note The source code for these examples is in the AWS Code Examples GitHub repository. Have feedback on a code example? Create an Issue in the code examples repo.

[ .NET ]

AWS SDK for .NET There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

using System; using System.Threading.Tasks; using Amazon.S3; using Amazon.S3.Model; class TransferAcceleration { /// /// The main method initializes the client object and sets the /// Amazon Simple Storage Service (Amazon S3) bucket name before /// calling EnableAccelerationAsync. /// public static async Task Main() { var s3Client = new AmazonS3Client(); const string bucketName = "doc-example-bucket"; await EnableAccelerationAsync(s3Client, bucketName); } /// /// This method sets the configuration to enable transfer acceleration /// for the bucket referred to in the bucketName parameter. /// /// An Amazon S3 client used to enable the /// acceleration on an Amazon S3 bucket. /// The name of the Amazon S3 bucket for which the /// method will be enabling acceleration. static async Task EnableAccelerationAsync(AmazonS3Client client, string bucketName) { try { var putRequest = new PutBucketAccelerateConfigurationRequest { BucketName = bucketName, AccelerateConfiguration = new AccelerateConfiguration { Status = BucketAccelerateStatus.Enabled, }, }; await client.PutBucketAccelerateConfigurationAsync(putRequest); var getRequest = new GetBucketAccelerateConfigurationRequest { BucketName = bucketName, }; var response = await client.GetBucketAccelerateConfigurationAsync(getRequest); Console.WriteLine($"Acceleration state = '{response.Status}' "); } catch (AmazonS3Exception ex) { Console.WriteLine($"Error occurred. Message:'{ex.Message}' when setting transfer acceleration"); } } } For API details, see PutBucketAccelerateConfiguration in AWS SDK for .NET API Reference.

For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有